
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<script src="../js/vue.min.js"></script>
		<script src="../js/vant.min.js"></script>
		<script src="../js/ajax.js"></script>
		<link rel="stylesheet" href="../css/index.css" />
		<script src="html5plus://ready"></script>
		<script src="../js/listener_other.js"></script>
		
		<title>更换联系方式</title>
	</head>
	<body placeholder="nihao">
		<div id="app">
			<van-row style="background-color:orangered; height:100px;line-height:46px;padding-top: 2%;">
			  <van-col span="2" offset="1" @click="onClickLeft" ><van-icon color="white" name="arrow-left" size="20px" style="margin-top: 29px;" /></van-col>
			 <van-col span="10" offset="4"><h2 style="color:white" >更换手机号</h2></van-col>
			 
			</van-row>
			<van-row style="margin-bottom: 10%;margin-top: 10%;">
			 	<van-col span="8" offset="2" >
			 	  	输入旧手机号：
			 	</van-col>
				<van-col span="12" offset="2"  >
			 	  	<input type="text" placeholder="请输入新手机号" id="phone" v-model="oldphone"  name="phone" style="border: none;" />
				</van-col>
			</van-row>
			<van-row style="margin-bottom: 10%;margin-top: 10%;">
			 	<van-col span="8" offset="2" >
			 	  	输入新手机号：
			 	</van-col>
				<van-col span="12" offset="2"  >
			 	  	<input type="text" placeholder="请输入新手机号" id="phone" v-model="phone"  name="phone" style="border: none;" />
				</van-col>
			</van-row>
			<van-row style="margin-top:5% ;">
				  <van-col span="14" offset="2" ><input type="text" placeholder="验证码(六位数字验证码)" v-model="yanzheng" id="yanzhengma"  name="yanzhengma" style="border: none;" /></van-col>
				  <van-col span="7" ><van-button id="yanzheng" type="danger" @click="yanzhengma" size="large">获取验证码</van-button></van-col>
							 
			</van-row>
			
			 
			  <van-row style="margin-top:10% ;">
			 	  <van-col span="20" offset="2" >
			 	  	<van-button type="danger" @click="save" size="large">保存</van-button>
			 	  	</van-col>
				  
				 
			 </van-row>
			  
			

		</div>
		<script type="text/javascript">
		

			var vm = new Vue({

				el: "#app",

				data: {
					oldphone:"",
					phone:"",
					yanzheng:""
					
					

				},

				methods: {
					onClickLeft: function() {
						plus.webview.close(plus.webview.currentWebview().id);
					},
					URL:function(url){
						plus.webview.open(url);
						
					},
					yanzhengma:function(){
						if(this.oldphone==localStorage.getItem("Phone")){
							ajax({
								url: "http://dsapi.ysd3g.com/api/SendChangePhoneCode",
								dataType:"jsonp",
								data: {
									key:localStorage.getItem("key"),
									phone:this.oldphone,
									
								},
								 success:function(res){
									console.log(JSON.stringify(res));
									if (res.Error) {
										vm.$toast.fail(res.Msg+res.Code);
									} else{
										alert("验证码已发送,请注意查收"+res.Code);
										vm.yanzheng=res.Code;
									}
								}
												
							
							})
						}else{
							vm.$toast.fail("旧手机号输入错误");
						}
						
						
						
						
					
					},
					save: function(res) {
								ajax({
									url: "http://dsapi.ysd3g.com/api/ChangePhone",
									dataType: "jsonp",
									data: {
										phone:vm.phone,
										key: localStorage.getItem("key"),
										code:vm.yanzheng
									},
									success:function(res) {
										if (res.Error) {
											vm.$toast.fail(res.Msg);
										} else{
											vm.$toast.success("修改成功");
											
										}
									}
								})
							
						
							
						
						
					}
				}

			});
		</script>
	</body>
</html>